//
//  DictProtocolDictionary.h
//  Lookup
//
//  Created by Mathieu on 17/07/06.
//  Copyright 2006 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>
#import "libdict.h"
#import "DictionaryMO.h"
#import "NetworkConnectionMonitor.h"


//The class for dictionaries that conform to the dict protocol. Each instance represents a dictionary.
@interface DictProtocolDictionary : DictionaryMO < NSCoding > {
	BOOL isConnected;
	NetworkConnectionMonitor *connectionMonitor;
	struct ld_conn *ldconn; //this is the basic connection handle that gets passed to all functions
}


#pragma mark API to Dictionaries
-(void)connect;
-(void)disconnect;
-(NSMutableString *)stringBlobOfDefinitions:(NSString *)word;
- (NSArray *)arrayOfDefinitions:(NSString *)word;
-(NSString *)dictType;
-(bool)isRemote;
-(NSString *)location;
#pragma mark Network Connection Monitor
-(NetworkConnectionMonitor *)networkConnectionMonitor;
-(void)createConnectionMonitor;

#pragma mark Archiving Support
- (void)encodeWithCoder:(NSCoder *)coder;
- (id)initWithCoder:(NSCoder *)coder;


#pragma mark Wapper to ld_dict
- (int)getRespNo:(NSString *)msg;
- (bool)checkOk:(int)respno;



//	connect [server] - connect to a server.
- (bool)connectTo:(NSString *)host port:(int)portNumber timeout:(int)timeout client:(NSString *)client debug:(bool)debug;
//	disconnect - disconnect from a server.
- (bool)closeConnection;
//	auth [username] - authenticate.
- (bool)authenticateUser:(NSString *)user password:(NSString *)password;
//	info - display server information.
- (NSString *)getServerInfo;
//	listdbs - list databases available.
- (struct ld_dbs **)getDbs;
//	liststrats - list strategies available.
- (struct ld_dbs **)getStrats;
//	setdb [db] - set database to use.
- (bool)setDb:(NSString *)db;
//	setstrat [strategy] - set strategy to use.
- (bool)setStrat:(NSString *)strat; //what's a strat?
//	define [word] - define a word.
- (struct ld_defanswer **)define:(NSString *)aWord; //the all important.
//	match [word] - match a word.
- (struct ld_matchanswer **)match:(NSString *)aWord; //what does this do?
//	getrep - get server response to last command.
- (NSString *)getSrvReply;
//	prerr - print error status.
- (NSString *)strError:(int)errnum;
- (int)getError;
//were private in original
//These switch back and forth between the internal bool representation and the normal one.

- (bool)convertToBool:(ld_bool)val;
- (ld_bool)convToLDBool:(bool)val;

#pragma mark Send NA to bindings
-(NSString *)indexLocation;

@end
